<!DOCTYPE html>



  


<html class="theme-next pisces use-motion" lang="zh-Hans">
<head><meta name="generator" content="Hexo 3.9.0">
  <meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<meta name="theme-color" content="#222">









<meta http-equiv="Cache-Control" content="no-transform">
<meta http-equiv="Cache-Control" content="no-siteapp">
















  
  
  <link href="/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css">







<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css">

<link href="/css/main.css?v=5.1.4" rel="stylesheet" type="text/css">


  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png?v=5.1.4">


  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png?v=5.1.4">


  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png?v=5.1.4">


  <link rel="mask-icon" href="/images/logo.svg?v=5.1.4" color="#222">





  <meta name="keywords" content="mapbox,">










<meta name="description" content="本文通过分析mapbox官网几个表达式示例，对初次阅读的疑难点进行辅助说明，来认识表达式。合理使用表达式可以优化代码和图层结构，减少图层数量，优化地图性能。 在图层的layout property, paint property和filter属性设置上可以使用表达式。表达式是定义了使用下述运算符的公式。mapbox提供的表达式运算符集包括：  用于对数值执行算术运算和其他运算的数学运算符 用于操纵">
<meta name="keywords" content="mapbox">
<meta property="og:type" content="article">
<meta property="og:title" content="认识mapbox表达式（expression）">
<meta property="og:url" content="https://straybirds.top/2019/09/23/了解mapbox表达式/index.html">
<meta property="og:site_name" content="StrayBirds">
<meta property="og:description" content="本文通过分析mapbox官网几个表达式示例，对初次阅读的疑难点进行辅助说明，来认识表达式。合理使用表达式可以优化代码和图层结构，减少图层数量，优化地图性能。 在图层的layout property, paint property和filter属性设置上可以使用表达式。表达式是定义了使用下述运算符的公式。mapbox提供的表达式运算符集包括：  用于对数值执行算术运算和其他运算的数学运算符 用于操纵">
<meta property="og:locale" content="zh-Hans">
<meta property="og:image" content="https://straybirds.top/uploads/2019/09/mapbox-expression-rgb.png">
<meta property="og:updated_time" content="2019-09-23T08:52:49.059Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="认识mapbox表达式（expression）">
<meta name="twitter:description" content="本文通过分析mapbox官网几个表达式示例，对初次阅读的疑难点进行辅助说明，来认识表达式。合理使用表达式可以优化代码和图层结构，减少图层数量，优化地图性能。 在图层的layout property, paint property和filter属性设置上可以使用表达式。表达式是定义了使用下述运算符的公式。mapbox提供的表达式运算符集包括：  用于对数值执行算术运算和其他运算的数学运算符 用于操纵">
<meta name="twitter:image" content="https://straybirds.top/uploads/2019/09/mapbox-expression-rgb.png">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Pisces',
    version: '5.1.4',
    sidebar: {"position":"left","display":"post","offset":12,"b2t":false,"scrollpercent":false,"onmobile":false},
    fancybox: true,
    tabs: true,
    motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},
    duoshuo: {
      userId: '0',
      author: '博主'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="https://straybirds.top/2019/09/23/了解mapbox表达式/">





  <title>认识mapbox表达式（expression） | StrayBirds</title>
  





  <script type="text/javascript">
    var _hmt = _hmt || [];
    (function() {
      var hm = document.createElement("script");
      hm.src = "https://hm.baidu.com/hm.js?1c055ff4eb7f9e86cf845aeff86f38d5";
      var s = document.getElementsByTagName("script")[0];
      s.parentNode.insertBefore(hm, s);
    })();
  </script>




</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">

  
  
    
  

  <div class="container sidebar-position-left page-post-detail">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/" class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">StrayBirds</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
      
        <p class="site-subtitle"></p>
      
  </div>

  <div class="site-nav-toggle">
    <button>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br>
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-about">
          <a href="/about/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-user"></i> <br>
            
            关于
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/archives/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br>
            
            归档
          </a>
        </li>
      

      
    </ul>
  

  
</nav>



 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="https://straybirds.top/2019/09/23/了解mapbox表达式/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="stray_brid_">
      <meta itemprop="description" content>
      <meta itemprop="image" content="/uploads/avatar.jpg">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="StrayBirds">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">认识mapbox表达式（expression）</h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2019-09-23T19:55:43+08:00">
                2019-09-23
              </time>
            

            

            
          </span>

          
            <span class="post-category">
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/mapbox/" itemprop="url" rel="index">
                    <span itemprop="name">mapbox</span>
                  </a>
                </span>

                
                
              
            </span>
          

          
            
              <span class="post-comments-count">
                <span class="post-meta-divider">|</span>
                <span class="post-meta-item-icon">
                  <i class="fa fa-comment-o"></i>
                </span>
                <a href="/2019/09/23/了解mapbox表达式/#comments" itemprop="discussionUrl">
                  <span class="post-comments-count valine-comment-count" data-xid="/2019/09/23/了解mapbox表达式/" itemprop="commentCount"></span>
                </a>
              </span>
            
          

          
          
             <span id="/2019/09/23/了解mapbox表达式/" class="leancloud_visitors" data-flag-title="认识mapbox表达式（expression）">
               <span class="post-meta-divider">|</span>
               <span class="post-meta-item-icon">
                 <i class="fa fa-eye"></i>
               </span>
               
                 <span class="post-meta-item-text">阅读次数&#58;</span>
               
                 <span class="leancloud-visitors-count"></span>
             </span>
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        <p>本文通过分析mapbox官网几个表达式示例，对初次阅读的疑难点进行辅助说明，来认识表达式。<br>合理使用表达式可以优化代码和图层结构，减少图层数量，优化地图性能。</p>
<p>在图层的<code>layout property</code>, <code>paint property</code>和<code>filter</code>属性设置上可以使用表达式。表达式是定义了使用下述运算符的公式。mapbox提供的表达式运算符集包括：</p>
<ul>
<li>用于对数值执行算术运算和其他运算的数学运算符</li>
<li>用于操纵布尔值和进行条件决策的逻辑运算符</li>
<li>用于操纵字符串的字符串运算符</li>
<li>数据操作员，提供对源功能属性的访问</li>
<li>摄像机操作员，提供对定义当前地图视图的参数的访问</li>
</ul>
<p>了解表达式首先要清除表达式的结构，它的形式是一个JSON数组。数组的第一个元素是表达式名称，后续元素都是表达式的参数。每个参数都是文字值（字符串，数字，布尔值或<code>null</code>）或其他表达式数组。也就是说，表达式里可以嵌套其他的表达式。</p>
<figure class="highlight json"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">[expression_name, argument_0, argument_1, ...]</span><br></pre></td></tr></table></figure>

<h4 id="数据表达式（Data-Expression）"><a href="#数据表达式（Data-Expression）" class="headerlink" title="数据表达式（Data Expression）"></a>数据表达式（Data Expression）</h4><p>数据表达式可以使用以下操作来获取数据的属性并用来确定外观:<code>get</code>,<code>has</code>,<code>id</code>,<code>geomerty-type</code>,<code>properties</code>,<code>feature-state</code>。</p>
<p>首先来了解下上述表达式类型：</p>
<ul>
<li><p><code>get</code><br>get会从当前feature的prperties中检索给定的属性值并返回，如果在第二个参数中提供了一个对象，则从该对象中检索属性值。<br>如果给了一个不存在的属性值，则返回null</p>
 <figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">[<span class="string">"get"</span>, string]: value</span><br><span class="line">[<span class="string">"get"</span>, string, object]: value</span><br><span class="line"></span><br><span class="line">[<span class="string">"get"</span>, <span class="string">"id"</span>] <span class="comment">// 当前数据中的id属性值</span></span><br><span class="line">[<span class="string">"get"</span>, <span class="string">"id"</span>, &#123;<span class="attr">id</span>: <span class="number">3</span>&#125;] <span class="comment">// 3</span></span><br></pre></td></tr></table></figure>
</li>
<li><p><code>has</code><br> 检测当前feature属性中是否存在一个属性值。如果提供了一个对象作为第二个参数，则检测该对象。  </p>
 <figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">[<span class="string">"has"</span>, string]: boolean</span><br><span class="line">[<span class="string">"has"</span>, string, object]: boolean</span><br></pre></td></tr></table></figure>
</li>
<li><p><code>id</code><br> 获取当前feature的id（如果有的话） </p>
 <figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">[<span class="string">"id"</span>]: value</span><br></pre></td></tr></table></figure>
</li>
<li><p><code>geomerty-type</code><br> 获取当前数据的geometry类型，返回值有： Point, MultiPoint, LineString, MultiLineString, Polygon, MultiPolygon</p>
 <figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">[<span class="string">"geometry-type"</span>]: string</span><br></pre></td></tr></table></figure>
</li>
<li><p><code>properties</code><br> 直接获取当前feature的properties对象。</p>
 <figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">[<span class="string">"properties"</span>]: object</span><br></pre></td></tr></table></figure>

<p> 一般情况下，使用<code>[&quot;get&quot;, &quot;property_name&quot;]</code>更合适</p>
</li>
<li><p><code>feature-state</code><br> 检索当前feature state的属性值，如果属性不存在，返回null<br> feature state不是数据的一部分，而且必须通过手动添加的。可以理解为feature的状态管理器。<br> feature通过id来分别，id必须是整数或可以转换为整数的字符串。也就是说，想使用feature state，必须在数据源中带有符合上述要求的id字段。<br> 可以直接看官方的<a href="https://docs.mapbox.com/mapbox-gl-js/example/hover-styles/" target="_blank" rel="noopener">使用示例</a></p>
</li>
</ul>
<p>接下来看官方示例：</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line">&#123;</span><br><span class="line">    <span class="string">"circle-color"</span>: [</span><br><span class="line">        <span class="string">"rgb"</span>,</span><br><span class="line">        <span class="comment">// red is higher when feature.properties.temperature is higher</span></span><br><span class="line">        [<span class="string">"get"</span>, <span class="string">"temperature"</span>],</span><br><span class="line">        <span class="comment">// green is always zero</span></span><br><span class="line">        <span class="number">0</span>,</span><br><span class="line">        <span class="comment">// blue is higher when feature.properties.temperature is lower</span></span><br><span class="line">        [<span class="string">"-"</span>, <span class="number">100</span>, [<span class="string">"get"</span>, <span class="string">"temperature"</span>]]  <span class="comment">//b 使用负号，</span></span><br><span class="line">    ]</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p>上例中，<code>rgb</code>是<a href="https://docs.mapbox.com/mapbox-gl-js/style-spec/#expressions-rgb" target="_blank" rel="noopener">mapbox</a>定义的一个样式表达式。摘录官方声明如下图：<br><img src="/uploads/2019/09/mapbox-expression-rgb.png" alt="rgb表达式" title="rbg表达式"></p>
<ol>
<li><code>get</code>是最常见的表达式之一，直接获取geojson数据中properties属性的值</li>
<li>“-“是一个<a href="https://docs.mapbox.com/mapbox-gl-js/style-spec/#expressions-math" target="_blank" rel="noopener">数学表达式</a>, 接收两个参数，获取第一个参数减去第二个参数的值，如果只有一个参数，则获取 0-参数 的值：<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">[<span class="string">"-"</span>, <span class="number">100</span>, <span class="number">70</span>]  <span class="comment">// 30</span></span><br><span class="line">[<span class="string">"-"</span>, <span class="number">30</span>]       <span class="comment">// -30</span></span><br></pre></td></tr></table></figure>

</li>
</ol>
<p><strong>某些layout和paint属性尚不支持数据表达式，某个样式是否支持需要看<code>Style Specification</code>文档中改样式下<code>data-driven styling</code>说明</strong></p>
<h4 id="相机表达式（Camera-expressions）"><a href="#相机表达式（Camera-expressions）" class="headerlink" title="相机表达式（Camera expressions）"></a>相机表达式（Camera expressions）</h4><p>从名字就能看出来，相机表达式跟地图的相机视角有关。它是使用<code>zoom</code>操作的表达式，允许图层外观随地图的缩放级别而变化。可以用来控制数据密度和深度的外观样式。<br>看官方示例：</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line">&#123;</span><br><span class="line">    <span class="string">"circle-radius"</span>: [</span><br><span class="line">        <span class="string">"interpolate"</span>, [<span class="string">"linear"</span>], [<span class="string">"zoom"</span>],</span><br><span class="line">        <span class="comment">// zoom is 5 (or less) -&gt; circle radius will be 1px</span></span><br><span class="line">        <span class="number">5</span>, <span class="number">1</span>,</span><br><span class="line">        <span class="comment">// zoom is 10 (or greater) -&gt; circle radius will be 5px</span></span><br><span class="line">        <span class="number">10</span>, <span class="number">5</span></span><br><span class="line">    ]</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p>先来了接下<code>interpolate</code>：<br>interpolate通过在输入和输出值之间进行插值，产生连续/平滑的结果。输入值可以是任何数值表达式，停止输入值必须时严格按照升序排列的数字。输出类型则必须是<code>number</code> <code>array&lt;Number&gt;</code> <code>color</code>。<br>插值类型：</p>
<ul>
<li><code>[&quot;linear&quot;]</code>：在一对停止之间线性插值，小于和略大于输入。</li>
<li><code>[&quot;exponential&quot;, base]</code>：在停靠点之间以指数方式插值，小于和大于输入。base控制输出增加的速率：较高的值使输出增加到更高的范围。当值接近1时，输出线性增加。</li>
<li><code>[&quot;cubic-bezier&quot;, x1, y1, x2, y2]</code>：使用给定控制点定义的三次贝塞尔曲线进行插值。</li>
</ul>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><span class="line">[<span class="string">"interpolate"</span>,</span><br><span class="line">    interpolation: [<span class="string">"linear"</span>] | [<span class="string">"exponential"</span>, base] | [<span class="string">"cubic-bezier"</span>, x1, y1, x2, y2 ],</span><br><span class="line">    input: number,</span><br><span class="line">    stop_input_1: number, <span class="attr">stop_output_1</span>: OutputType,</span><br><span class="line">    stop_input_n: number, <span class="attr">stop_output_n</span>: OutputType, ...</span><br><span class="line">]: OutputType (number, array&lt;number&gt;, or Color)</span><br><span class="line"></span><br><span class="line">[</span><br><span class="line">    <span class="string">"interpolate"</span>, [<span class="string">"linear"</span>], [<span class="string">"zoom"</span>],</span><br><span class="line">    <span class="comment">// zoom is 5 (or less) -&gt; circle radius will be 1px</span></span><br><span class="line">    <span class="number">5</span>, <span class="number">1</span>,</span><br><span class="line">    <span class="comment">// zoom is 10 (or greater) -&gt; circle radius will be 5px</span></span><br><span class="line">    <span class="number">10</span>, <span class="number">5</span></span><br><span class="line">]</span><br></pre></td></tr></table></figure>

<p>再回看上面的例子，在这种情况下，表达式表示当缩放级别为5或更低时，圆半径应为1像素，当缩放为10或更高时，圆半径应为5像素。 在两者之间，半径将在1到5个像素之间进行线性插值。</p>
<p>相机表达式可以在任何使用表达式的地方使用。但是当它用作<code>layout property</code> 和 <code>paint property</code>时，必须采取以下形式：</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br></pre></td><td class="code"><pre><span class="line">[ <span class="string">"interpolate"</span>, interpolation, [<span class="string">"zoom"</span>], ... ]</span><br><span class="line"></span><br><span class="line">[ <span class="string">"step"</span>, [<span class="string">"zoom"</span>], ... ]</span><br><span class="line"></span><br><span class="line">[</span><br><span class="line">    <span class="string">"let"</span>,</span><br><span class="line">    ... variable bindings...,</span><br><span class="line">    [ <span class="string">"interpolate"</span>, interpolation, [<span class="string">"zoom"</span>], ... ]</span><br><span class="line">]</span><br><span class="line"></span><br><span class="line">[</span><br><span class="line">    <span class="string">"let"</span>,</span><br><span class="line">    ... variable bindings...,</span><br><span class="line">    [ <span class="string">"step"</span>, [<span class="string">"zoom"</span>], ... ]</span><br><span class="line">]</span><br></pre></td></tr></table></figure>

<blockquote>
<p>mapbox 表达式官方文档<a href="https://docs.mapbox.com/mapbox-gl-js/style-spec/#expressions" target="_blank" rel="noopener">https://docs.mapbox.com/mapbox-gl-js/style-spec/#expressions</a></p>
</blockquote>

      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/tags/mapbox/" rel="tag"># mapbox</a>
          
        </div>
      

      
      
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/2019/09/11/hexo建站记录/" rel="next" title="hexo建站记录">
                <i class="fa fa-chevron-left"></i> hexo建站记录
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/2019/11/27/sass常用语法整理/" rel="prev" title="sass常用语法整理">
                sass常用语法整理 <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </div>
  
  
  
  </article>



    <div class="post-spread">
      
    </div>
  </div>


          </div>
          


          

  
    <div class="comments" id="comments">
    </div>
  



        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap">
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview-wrap">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview-wrap sidebar-panel">
        <div class="site-overview">
          <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
            
              <img class="site-author-image" itemprop="image" src="/uploads/avatar.jpg" alt="stray_brid_">
            
              <p class="site-author-name" itemprop="name">stray_brid_</p>
              <p class="site-description motion-element" itemprop="description">What is an ocean, but mutiple of drops.</p>
          </div>

          <nav class="site-state motion-element">

            
              <div class="site-state-item site-state-posts">
              
                <a href="/archives/">
              
                  <span class="site-state-item-count">12</span>
                  <span class="site-state-item-name">日志</span>
                </a>
              </div>
            

            
              
              
              <div class="site-state-item site-state-categories">
                <a href="/categories/index.html">
                  <span class="site-state-item-count">3</span>
                  <span class="site-state-item-name">分类</span>
                </a>
              </div>
            

            
              
              
              <div class="site-state-item site-state-tags">
                <a href="/tags/index.html">
                  <span class="site-state-item-count">7</span>
                  <span class="site-state-item-name">标签</span>
                </a>
              </div>
            

          </nav>

          

          

          
          

          
          

          

        </div>
      </section>

      
      <!--noindex-->
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
              
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-4"><a class="nav-link" href="#数据表达式（Data-Expression）"><span class="nav-number">1.</span> <span class="nav-text">数据表达式（Data Expression）</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#相机表达式（Camera-expressions）"><span class="nav-number">2.</span> <span class="nav-text">相机表达式（Camera expressions）</span></a></li></ol></div>
            

          </div>
        </section>
      <!--/noindex-->
      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright">&copy; <span itemprop="copyrightYear">2020</span>
  <span class="with-love">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">stray_brid_</span>

  
</div>


  <div class="powered-by">由 <a class="theme-link" target="_blank" href="https://hexo.io">Hexo</a> 强力驱动</div>



  <span class="post-meta-divider">|</span>



  <div class="theme-info">主题 &mdash; <a class="theme-link" target="_blank" href="https://github.com/iissnan/hexo-theme-next">NexT.Pisces</a> v5.1.4</div>




        







        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
      </div>
    

    

  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  












  
  
    <script type="text/javascript" src="/lib/jquery/index.js?v=2.1.3"></script>
  

  
  
    <script type="text/javascript" src="/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>
  

  
  
    <script type="text/javascript" src="/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>
  

  
  
    <script type="text/javascript" src="/lib/velocity/velocity.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>
  


  


  <script type="text/javascript" src="/js/src/utils.js?v=5.1.4"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=5.1.4"></script>



  
  


  <script type="text/javascript" src="/js/src/affix.js?v=5.1.4"></script>

  <script type="text/javascript" src="/js/src/schemes/pisces.js?v=5.1.4"></script>



  
  <script type="text/javascript" src="/js/src/scrollspy.js?v=5.1.4"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=5.1.4"></script>



  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=5.1.4"></script>



  


  




	





  





  










  <script src="//cdn1.lncld.net/static/js/3.0.4/av-min.js"></script>
  <script src="//cdn.jsdelivr.net/npm/valine@1.3.4/dist/Valine.min.js"></script>
  
  <script type="text/javascript">
    var GUEST = ['nick','mail','link'];
    var guest = 'nick,mail,link';
    guest = guest.split(',').filter(item=>{
      return GUEST.indexOf(item)>-1;
    });
    new Valine({
        el: '#comments' ,
        verify: true,
        notify: false,
        appId: '8g39VF5cW0SljcelPGGyN4jm-gzGzoHsz',
        appKey: 'pKPp2FxqhUAUBIPsRabgUW5M',
        placeholder: 'Just go go',
        avatar:'robohash',
        guest_info:guest,
        pageSize:'10' || 10,
    });
  </script>



  





  

  
  <script src="https://cdn1.lncld.net/static/js/av-core-mini-0.6.4.js"></script>
  <script>AV.initialize("8g39VF5cW0SljcelPGGyN4jm-gzGzoHsz", "pKPp2FxqhUAUBIPsRabgUW5M");</script>
  <script>
    function showTime(Counter) {
      var query = new AV.Query(Counter);
      var entries = [];
      var $visitors = $(".leancloud_visitors");

      $visitors.each(function () {
        entries.push( $(this).attr("id").trim() );
      });

      query.containedIn('url', entries);
      query.find()
        .done(function (results) {
          var COUNT_CONTAINER_REF = '.leancloud-visitors-count';

          if (results.length === 0) {
            $visitors.find(COUNT_CONTAINER_REF).text(0);
            return;
          }

          for (var i = 0; i < results.length; i++) {
            var item = results[i];
            var url = item.get('url');
            var time = item.get('time');
            var element = document.getElementById(url);

            $(element).find(COUNT_CONTAINER_REF).text(time);
          }
          for(var i = 0; i < entries.length; i++) {
            var url = entries[i];
            var element = document.getElementById(url);
            var countSpan = $(element).find(COUNT_CONTAINER_REF);
            if( countSpan.text() == '') {
              countSpan.text(0);
            }
          }
        })
        .fail(function (object, error) {
          console.log("Error: " + error.code + " " + error.message);
        });
    }

    function addCount(Counter) {
      var $visitors = $(".leancloud_visitors");
      var url = $visitors.attr('id').trim();
      var title = $visitors.attr('data-flag-title').trim();
      var query = new AV.Query(Counter);

      query.equalTo("url", url);
      query.find({
        success: function(results) {
          if (results.length > 0) {
            var counter = results[0];
            counter.fetchWhenSave(true);
            counter.increment("time");
            counter.save(null, {
              success: function(counter) {
                var $element = $(document.getElementById(url));
                $element.find('.leancloud-visitors-count').text(counter.get('time'));
              },
              error: function(counter, error) {
                console.log('Failed to save Visitor num, with error message: ' + error.message);
              }
            });
          } else {
            var newcounter = new Counter();
            /* Set ACL */
            var acl = new AV.ACL();
            acl.setPublicReadAccess(true);
            acl.setPublicWriteAccess(true);
            newcounter.setACL(acl);
            /* End Set ACL */
            newcounter.set("title", title);
            newcounter.set("url", url);
            newcounter.set("time", 1);
            newcounter.save(null, {
              success: function(newcounter) {
                var $element = $(document.getElementById(url));
                $element.find('.leancloud-visitors-count').text(newcounter.get('time'));
              },
              error: function(newcounter, error) {
                console.log('Failed to create');
              }
            });
          }
        },
        error: function(error) {
          console.log('Error:' + error.code + " " + error.message);
        }
      });
    }

    $(function() {
      var Counter = AV.Object.extend("Counter");
      if ($('.leancloud_visitors').length == 1) {
        addCount(Counter);
      } else if ($('.post-title-link').length > 1) {
        showTime(Counter);
      }
    });
  </script>



  

  
<script>
(function(){
    var bp = document.createElement('script');
    var curProtocol = window.location.protocol.split(':')[0];
    if (curProtocol === 'https') {
        bp.src = 'https://zz.bdstatic.com/linksubmit/push.js';        
    }
    else {
        bp.src = 'http://push.zhanzhang.baidu.com/push.js';
    }
    var s = document.getElementsByTagName("script")[0];
    s.parentNode.insertBefore(bp, s);
})();
</script>


  
  

  

  

  

</body>
</html>
